from zope.interface import implements, Interface

from Products.Five import BrowserView
from Products.CMFCore.utils import getToolByName
from zope.component import getMultiAdapter

from my315ok.researchevent import researcheventMessageFactory as _


class IachievementView(Interface):
    """
    achievement view interface
    """

    def test():
        """ test method"""


class achievementView(BrowserView):
    """
    achievement browser view
    """
    implements(IachievementView)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    @property
    def portal_catalog(self):
        return getToolByName(self.context, 'portal_catalog')

    @property
    def portal(self):
        return getToolByName(self.context, 'portal_url').getPortalObject()

    def img_tag(self,scale="mini"):
        imgfd = self.context.getField("image")
        return imgfd.tag(self.context,scale=scale)
        
        
    def parent(self):
        parent = self.context.aq_inner.aq_parent
        return parent
    def parenturl(self):
        parenturl = self.parent().absolute_url()
        return parenturl
    def gettime(self):
        """fetch parent datetime"""
        pview = getMultiAdapter((self.parent(), self.request), name=u'event_view')
        return pview.getOccurrencetime()
    def test(self):
        """
        test method
        """
        dummy = _(u'a dummy string')

        return {'dummy': dummy}
